using System;
using System.Threading;
using Microsoft.SPOT;
using SecretLabs.NETMF.Hardware;
using System.IO.Ports;
using System.Text;

#if MINI
using SecretLabs.NETMF.Hardware.NetduinoMini;
#else
using SecretLabs.NETMF.Hardware.Netduino;
#endif

namespace codebase
{
    public class SerialMonitor : BaseProgramSPE
    {

#if MINI
        SerialPort sr = new SerialPort("COM2");
#else
        SerialPort sr = new SerialPort("COM1");
#endif

        UI.WindowManager manForms;
        public windowMain formMain;

        public Terminal terminal;
        public Settings settings;

        public override void Initialize()
        {
            base.Initialize();

            initMedia(); // Init Media as we use the SD Card
            demoRGB(); // Small initial Display Test
            demoVideo(); // Small Video Test
            createGUI(); // Generate User Interface
        }


        public override void Update()
        {
            base.Update();

            terminal.readSerialData();
        }

        public override void Draw()
        {
            base.Draw();
        }

        void createGUI()
        {
            terminal = new Terminal(this, sr);
            settings = new Settings();
#if NDS
            manForms = new UI.WindowManager(screen, touchscreen);
#else
            manForms = new UI.WindowManager(screen);
#endif
            Window0 win0 = new Window0(manForms);
            win0.Visible = true;

            manForms.Redraw();           
        }
    }
}
